<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="#{webContext.skin0Culomns}"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="center">
        <h:form id="articlesForm">
            <!--  XXXXXXXXXXXXXXXX MENU XXXXXXXXXXXXXXXXXX -->
            <p:toolbar>
                <p:toolbarGroup align="left">
                    <p:commandButton type="submit"
                                     value="#{ml.tr('Add')}"
                                     image="ui-icon-plus"
                                     actionListener="#{man.redirect(lm.ml('cms/add.xhtml'))}" />
                    <p:commandButton type="submit"
                                     value="#{ml.tr('Show')}"
                                     image="ui-icon-search"
                                     actionListener="#{man.redirect(lm.ml('cms/show.xhtml?p1=',
                                                       cmsArticleList.selectedArticle.id))}" />
                    <p:commandButton type="submit"
                                     value="#{ml.tr('Edit')}"
                                     image="ui-icon-pencil"
                                     actionListener="#{man.redirect(lm.ml('cms/edit.xhtml?p1=',
                                                       cmsArticleList.selectedArticle.id))}" />
                    <p:commandButton type="button"
                                     value="#{ml.tr('Delete')}"
                                     image="ui-icon ui-icon-circle-close"
                                     onclick="confirmationDelete.show()"
                                     update="display" />
                    <p:confirmDialog message="#{ml.tr('Are you sure?')}"  
                                     header="#{ml.tr('Deleting articles')}" 
                                     severity="alert" widgetVar="confirmationDelete">  
                        <p:commandButton value="#{ml.tr('Yes')}" 
                                         update="articleList" 
                                         oncomplete="confirmationDelete.hide(); statusDialog.hide();"
                                         onclick="statusDialog.show()"
                                         actionListener="#{cmsArticleList.deleteSelectedArticle}"/>  
                        <p:commandButton value="#{ml.tr('No')}" 
                                         onclick="confirmationDelete.hide()" 
                                         type="button" />
                    </p:confirmDialog>
                    <ui:include src="#{webContext.skinPatch}statusDialog.xhtml" />
                    <p:divider />
                </p:toolbarGroup>
                <p:divider />
                <p:toolbarGroup>
                    <p:menuButton value="#{ml.tr('Export')}">
                        <p:menuitem>
                            <h:commandLink>
                                <h:outputText value="Csv" />
                                <p:dataExporter type="csv" target="articleList" 
                                                fileName="#{ml.tr('file_articles')}" 
                                                excludeColumns="3,4" />
                            </h:commandLink>
                        </p:menuitem>
                    </p:menuButton>
                </p:toolbarGroup>
            </p:toolbar>
            <!--  XXXXXXXXXXXXXXXX TABULKA XXXXXXXXXXXXXXXXXX -->
            <p:dataTable id="articleList" var="article" value="#{cmsArticleList.cms.articles}"
                         paginator="true" rows="12" selectionMode="single" selection="#{cmsArticleList.selectedArticle}">

                <f:facet name="header">
                    "#{ml.tr('List of articles')}"
                </f:facet>

                <p:column filterBy="#{article.title}"
                          headerText="#{ml.tr('Title')}"
                          filterMatchMode="contains">
                    <h:outputText value="#{article.title}" />
                </p:column>

                <p:column filterBy="#{article.author.firstname}"
                          headerText="#{ml.tr('Name')}"
                          filterMatchMode="contains">
                    <h:outputText value="#{article.author.firstname}" />
                </p:column>

                <p:column filterBy="#{article.author.lastname}"
                          headerText="#{ml.tr('Surname')}"
                          filterMatchMode="contains">
                    <h:outputText value="#{article.author.lastname}" />
                </p:column>

                <p:column filterBy="#{article.language.isoLanguage}"
                          headerText="#{ml.tr('Language')}"
                          filterMatchMode="contains">
                    <h:outputText value="#{article.language.isoLanguage}" />
                </p:column>

                <p:column filterBy="#{article.timeCreate.toLocaleString()}"
                          headerText="#{ml.tr('Created')}"
                          filterMatchMode="contains">
                    <h:outputText value="#{article.timeCreate.toLocaleString()}" />
                </p:column>

            </p:dataTable>
        </h:form>
    </ui:define>

</ui:composition>